<text><span class="style1">his stack contains XFCNs that compress data using the Lempel-Ziv-Welch algorithm. One pair of XFCNs compresses and uncompresses files (including the resource fork). Another pair deals with HyperTalk strings. You might use these XFCNs if you wanted to manipulate compressed data under the control of a script.This stack contains five XFCNs. All of them follow the convention of returning a string whose first word is "error" if something goes wrong. This software works with HyperCard versions 1.x and 2.x.</span><span class="style12">CompressFile(infile, outfile)</span><span class="style1">This XFCN reads compresses the data and resource forks of </span><span class="style12">infile</span><span class="style1"> and writes the results to </span><span class="style12">outfile</span><span class="style1">. The input and output files may not be the same. </span><span class="style12">Outfile</span><span class="style1"> will have type </span><span class="style12">hcLZ</span><span class="style1">. The creator, file type, and file name of the original file are recorded in the compressed file.</span><span class="style12">UncompressFile(infile, [outfile])</span><span class="style1">This XFCN uncompresses the file specified by the first argument. If no output file is given, the file name recorded in the compressed file is used. The creator and file type of the original file are restored. The input and output files may not be the same.</span><span class="style12">FSDelete(file)</span><span class="style1">This XFCN deletes the indicated file.</span><span class="style12">CompressString(text)</span><span class="style13"></span><span class="style1">This XFCN takes any string as an argument, compresses it, and returns the compressed text. The return value always starts with the two characters #W.</span><span class="style12">UncompressString(compressedText)</span><span class="style1">This XFCN takes a compressed string as produced by </span><span class="style12">CompressString()</span><span class="style1">. It returns the original string.</span></text>
</content>
<name></name>
<script></script>
</card>
card_2998.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card PUBLIC "-//Apple, Inc.//DTD card V 2.0//EN" "" >
<script>on mouseUpglobal statsset cursor to 4put "" into cd fld "out"put CompressString(cd fld "in") into cd fld "out"put (the number of chars of cd fld "in")&&"bytes" into cd fld "insize"put (the number of chars of cd fld "out")&&"bytes" into cd fld "outsize"end mouseUp</script>
</part>
<part>
<id>11</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>208</left>
<top>103</top>
<right>246</right>
<bottom>137</bottom>
</rect>
<style>rectangle</style>
<showName> <false /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>4895</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Uncompress</name>
<script>on mouseUpglobal statsset cursor to 4put "" into cd fld "in"put UncompressString(cd fld "out") into cd fld "in"put (the number of chars of cd fld "in")&&"bytes" into cd fld "insize"put (the number of chars of cd fld "out")&&"bytes" into cd fld "outsize"end mouseUp</script>
</part>
<part>
<id>13</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>35</left>
<top>255</top>
<right>135</right>
<bottom>277</bottom>
</rect>
<style>roundrect</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Compress</name>
<script>on mouseUpglobal statsanswer file "File to compress:" -- of type "xxxx"put it into infileif infile is "" then exit to hypercardput infile && "(compressed)" into outfileset cursor to 4put the ticks into t1put CompressFile(infile, outfile) into zzif zz <> "" thenanswer zzend ifput ((the ticks) - t1) / 60 into statsend mouseUp</script>
</part>
<part>
<id>14</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>145</left>
<top>255</top>
<right>245</right>
<bottom>277</bottom>
</rect>
<style>roundrect</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Uncompress</name>
<script>on mouseUpglobal statsanswer file "File to uncompress:" of type "hcLZ"put it into infileif infile is "" then exit to hypercardask file "Output file:"put it into outfileif outfile is "" then exit to hypercardset cursor to 4put the ticks into t1put UncompressFile(infile, outfile) into zzif zz <> "" thenanswer zzend ifput ((the ticks) - t1) / 60 into statsend mouseUp</script>
</part>
<part>
<id>15</id>
<type>button</type>
<visible> <true /> </visible>
<reserved5> 0 </reserved5>
<reserved4> 0 </reserved4>
<reserved3> 0 </reserved3>
<reserved2> 0 </reserved2>
<reserved1> 0 </reserved1>
<enabled> <true /> </enabled>
<rect>
<left>254</left>
<top>255</top>
<right>354</right>
<bottom>277</bottom>
</rect>
<style>roundrect</style>
<showName> <true /> </showName>
<highlight> <false /> </highlight>
<autoHighlight> <true /> </autoHighlight>
<sharedHighlight> <true /> </sharedHighlight>
<family>0</family>
<titleWidth>0</titleWidth>
<icon>0</icon>
<textAlign>center</textAlign>
<font>Chicago</font>
<textSize>12</textSize>
<textStyle>plain</textStyle>
<name>Delete</name>
<script>on mouseUpanswer file "File to delete:"put it into flif fl <> "" thenput FSDelete(fl) into zzif zz <> "" thenanswer zzend ifend ifend mouseUp</script>
<text>Here is some text to compress:This stack contains XFCNs that compress data using the Lempel-Ziv-Welch algorithm. One pair of XFCNs compresses and uncompresses files (including the resource fork). Another pair deals with HyperTalk strings.This stack contains five XFCNs. All of them follow the convention of returning a string whose first word is "error" if something goes wrong. This software works with HyperCard versions 1.x and 2.x.CompressFile(infile, outfile)This XFCN reads compresses the data and resource forks of infile and writes the results to outfile. The input and output files may not be the same. Outfile will have type hcLZ. The creator, file type, and file name of the original file are recorded in the compressed file.UncompressFile(infile, [outfile])This XFCN uncompresses the file specified by the first argument. If no output file is given, the file name recorded in the compressed file is used. The creator and file type of the original file are restored. The input and output files may not be the same.FSDelete(file)This XFCN deletes the indicated file.CompressString(text)This XFCN takes any string as an argument, compresses it, and returns the compressed text. The return value always starts with the two characters #W.UncompressString(compressedText)This XFCN takes a compressed string as produced by CompressString(). It returns the original string.</text>
</content>
<name></name>
<script>on TestString-- loop forever, testing CompressString() and UncompressString()set cursor to busyrepeatput cd fld "in" into xrepeat with i = 1 to 20put CompressString(x) into xCheck xend repeatrepeat with i = 1 to 20put UncompressString(x) into xCheck xend repeatif x <> cd fld "in" thenanswer "strings do not match"end ifend repeatend TestStringon TestFile-- loop forever, testing CompressFile() and UncompressFile()answer file "Test file to compress?"put it into flif fl is "" then exit to hypercardset cursor to busyCheck CompressFile(fl, "junk0 (compressed)")Check UncompressFile("junk0 (compressed)", "junk0")Check FSDelete("junk0 (compressed)")repeatCheck CompressFile("junk0", "junk0 (compressed)")Check FSDelete("junk0")Check UncompressFile("junk0 (compressed)")Check FSDelete("junk0 (compressed)")end repeatend TestFileon Check sif word 1 of s is "error" thenanswer sexit to hypercardend ifset cursor to busyend Check</script>
</card>
card_3862.xml
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card PUBLIC "-//Apple, Inc.//DTD card V 2.0//EN" "" >
<text><span class="style10">he XFCNs in this stack are copyright 1991 by Differential Development. They are shareware; please send $12 per copy you use to: Differential Development P.O. Box 1044 Harvard Square Station Cambridge, MA 02238In return, we will send you updates and forthcoming shareware.</span></text>
</content>
<content>
<layer>card</layer>
<id>2</id>
<text><span class="style11">ompression for HyperCard</span></text>
</content>
<content>
<layer>card</layer>
<id>3</id>
<text>This stack contains XCMDs to compress and uncompress files, including both the data and resource forks. It also contains XCMDs to compress and uncompress strings, so that you can keep compressed text in HyperCard fields and variables.</text>